import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import path from 'path';
import scss from 'sass';
// https://vitejs.dev/config/
export default defineConfig({
  plugins: [react()],
  css: {
    // 配置 CSS 预处理器
    preprocessorOptions: {
      scss: {
        // 这里可以添加sass的配置选项
      },
    },
  },
  build: {
    outDir: './build',
    //打包环境移除console.log，debugger
    minify: 'terser',
    terserOptions: {
      compress: {
        drop_console: true,
        drop_debugger: true
      }
    },
    //打包文件按照类型分文件夹显示
    rollupOptions: {
      output: {
        chunkFileNames: 'js/[name]-[hash].js',
        entryFileNames: 'js/[name]-[hash].js',
        assetFileNames: '[ext]/[name]-[hash].[ext]'
      }
    },
  },
  resolve: {
    alias: {
      '@': path.resolve(__dirname, './src'),
      '~': path.resolve(__dirname, './')
    }
  }
})
